@layout("/common/_container_class.html"){
<style>
    /*layui 元素样式改写*/
    .layui-btn-sm{line-height: normal; font-size: 12.5px;}
    .layui-table-view .layui-table-body{min-height: 256px;}
    .layui-table-cell .layui-input.layui-unselect{height: 30px; line-height: 30px;}
    .layui-table-view .layui-table td{ overflow: visible}
    /*设置 layui 表格中单元格内容溢出可见样式*/
    .table-overlay .layui-table-view,
    .table-overlay .layui-table-box,
    .table-overlay .layui-table-body{overflow: visible;}
    .table-overlay .layui-table-cell{height: auto; overflow: visible;}
    /*文本对齐方式*/
    .text-center{text-align: center;}
</style>
<div class="layui-fluid" id="editClass" style="height: 440px">
    <div class="layui-card">
        <div class="layui-card-body" style="overflow: scroll">
            <div class="layui-carousel" id="stepForm" lay-filter="stepForm" style="margin: 0 auto;">
                <div id="updateClass_class_edit">
                    <input type="hidden" id="classIds" value="${classIds}"/>
                    <form class="layui-form" lay-filter="text1" style="margin: 0 auto;max-width: 500px;padding-top: 10px;">
                        <input id="classId" type="hidden" value="${ptClass.id}">
                        <input id="orgId" type="hidden" value="${ptClass.orgId}">
                        <input id="schoolYear" type="hidden" value="${schoolYear}">
                        <div class="layui-card-body layui-text">
                            <div id="toolbar">
                                <div>
                                    <button type="button" class="layui-btn layui-btn-sm addStu" title="添加一行">
                                        <i class="layui-icon layui-icon-add-1"></i> 添加一行
                                    </button>
                                </div>
                            </div>
                            <div id="tableRes" class="table-overlay">
                                <table id="dataTable" lay-filter="dataTable" class="layui-hide"></table>
                                <script type="text/html" id="barDemo">
                                    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="iconfont icon-shanchu"></i>删除</a>
                                </script>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button type="button" class="layui-btn fourPre" id="fourstepPre"
                                        data-id="${preClassInfo.id}">${preClassInfo.id==null?'上一步':'上一个班级'}
                                </button>
                                <button class="layui-btn" lay-submit lay-filter="formStep4" id="fourstepNext"
                                        data-id="${nextClassInfo.id}">
                                    ${nextClassInfo.id==null?'下一步':'下一个班级'}
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

@}
<script src="${ctxPath}/static/modular/system/ptClass/classUpdate.js"></script>
<script type="text/javascript">
    //layui 模块化引用
    layui.use(['jquery', 'table', 'layer'], function () {
        var $ = layui.$, table = layui.table, form = layui.form, layer = layui.layer;

        //数据表格实例化
        var tbWidth = $("#tableRes").width();
        var layTableId = "layTable";
        var tableIns = table.render({
            elem: '#dataTable',
            id: layTableId,
            url: Feng.ctxPath+'/ptClass/classupdate/findStudentList/'+$("#classId").val(),
            width: tbWidth,
            page: true,
            loading: true,
            even: false, //不开启隔行背景
            cols: [[
                {title: '序号', type: 'numbers'},
                {field: 'userName', title: '学生姓名', align: 'center'},
                {field: 'userId', title: '用户id', align: 'center',hide: true},
                {fixed: 'right', title: '操作', align: 'center', toolbar: '#barDemo'}
            ]],
            done:function () {
                $("[data-field=‘userId’]").css('display','none');
            }
        });

        //添加
        $(".addStu").click(function () {
            var index = layer.open({
                type: 2,
                title: '添加管理员',
                area: ['400px', '300px'], //宽高
                fix: false, //不固定
                maxmin: true,
                content:Feng.ctxPath + '/ptClass/classupdate/addClassStudent?orgId=' + $("#orgId").val()+"&schoolYear="+$("#schoolYear").val()+"&classId="+$("#classId").val()
            });
            this.layerIndex = index;
        });
function delStu(id) {

    var ajax = new $ax(Feng.ctxPath + "/ptClass/deleteClassUserByUserId/"+id+"?schoolYear="+$("#schoolYear").val(), function (data) {
        if (data.code===200){
            Feng.success(data.msg);
            tableIns.reload('layTable');
        }else {
            Feng.error(data.msg);
        }
    }, function (data) {
        Feng.error(data.msg);
    });
    ajax.start();
}
        //监听工具条
        table.on('tool(dataTable)', function (obj) {
            var data = obj.data, event = obj.event, tr = obj.tr; //获得当前行 tr 的DOM对象;
            console.log(data);
            switch (event) {
                case "del":
                    layer.confirm('真的删除该学生吗？', function (index) {
                        layer.close(index);
                            delStu(data.userId);
                    });
                    break;
            }
        });
    });
</script>